public class Solution {
    //数组中两元素最大乘积
    public int maxProduct(int[] nums) {
        int maxa = Integer.MIN_VALUE;
        int maxb = Integer.MIN_VALUE;
        int a = 0;
        int n = nums.length;
        for(int i = 0; i < nums.length; i++) {
            if(maxa <= nums[i]) {
                maxa = nums[i];
                //记录最大值下标
                a = i;
            }
        }
        for(int i = 0; i < n; i++) {
            if(i == a) {
                //遇到最大值下标跳过
                continue;
            }
            if(nums[i] > maxb) {
                maxb = nums[i];
            }
        }

        return (maxa-1) * (maxb-1);
    }
    
}
